const Mock = require('mockjs')
// 设备协议
const pagreement = Mock.mock({
    'items|30': [{
        index: '@increment',   //序号
        type:() => {                                                       
            const randomLength = Mock.Random.integer(2, 3);
            let chineseCharacters = '';
            for (let i = 0; i < randomLength; i++) {
                chineseCharacters += String.fromCharCode(Mock.Random.integer(0x4e00, 0x9fa5));
            }
            return chineseCharacters;
        },     //设备类型
        manufacturer: () => {                                                       
            const randomLength = Mock.Random.integer(8, 10);
            let chineseCharacters = '';
            for (let i = 0; i < randomLength; i++) {
                chineseCharacters += String.fromCharCode(Mock.Random.integer(0x4e00, 0x9fa5));
            }
            return chineseCharacters;
        },     //设备厂家
        model: '@upper()@string("number", 4)',    //设备型号
        protocol: '@upper()@string("number", 4)',   //设备协议包
   
    }]
});
// 主机报警
const hostalarm = Mock.mock({
    'items|30': [{
        index: '@increment',   //序号
        manufacturer: () => {                                                       
            const randomLength = Mock.Random.integer(2, 4);
            let chineseCharacters = '';
            for (let i = 0; i < randomLength; i++) {
                chineseCharacters += String.fromCharCode(Mock.Random.integer(0x4e00, 0x9fa5));
            }
            return chineseCharacters;
        },     //主机厂家
        model: '@upper()@string("number", 4)',    //设备型号
        breakdown:() => {                                                       
            const randomLength = Mock.Random.integer(5, 6);
            let chineseCharacters = '';
            for (let i = 0; i < randomLength; i++) {
                chineseCharacters += String.fromCharCode(Mock.Random.integer(0x4e00, 0x9fa5));
            }
            return chineseCharacters;
        },     //主机故障
   
    }]
})
// 设备标签
const plabel = Mock.mock({
    'items|30': [{
        index: '@increment',   //序号
        type: () => {                                                       
            const randomLength = Mock.Random.integer(2, 4);
            let chineseCharacters = '';
            for (let i = 0; i < randomLength; i++) {
                chineseCharacters += String.fromCharCode(Mock.Random.integer(0x4e00, 0x9fa5));
            }
            return chineseCharacters;
        },     //设备类型
        label_name:() => {                                                       
            const randomLength = Mock.Random.integer(5, 6);
            let chineseCharacters = '';
            for (let i = 0; i < randomLength; i++) {
                chineseCharacters += String.fromCharCode(Mock.Random.integer(0x4e00, 0x9fa5));
            }
            return chineseCharacters;
        },      //标签名称
        Identification: '@word()_@word()',   //系统识别号
   
    }]
})
// 设备分析
const panalyze = Mock.mock({
    'items|30': [{
        index: '@increment',   //序号
        type: () => {                                                       
            const randomLength = Mock.Random.integer(2, 4);
            let chineseCharacters = '';
            for (let i = 0; i < randomLength; i++) {
                chineseCharacters += String.fromCharCode(Mock.Random.integer(0x4e00, 0x9fa5));
            }
            return chineseCharacters;
        },     //设备类型
        analyze_name:() => {                                                       
            const randomLength = Mock.Random.integer(5, 6);
            let chineseCharacters = '';
            for (let i = 0; i < randomLength; i++) {
                chineseCharacters += String.fromCharCode(Mock.Random.integer(0x4e00, 0x9fa5));
            }
            return chineseCharacters;
        },      //分析名称
        argument: () => {                                                       
            const randomLength = Mock.Random.integer(5, 6);
            let chineseCharacters = '';
            for (let i = 0; i < randomLength; i++) {
                chineseCharacters += String.fromCharCode(Mock.Random.integer(0x4e00, 0x9fa5));
            }
            return chineseCharacters;
        },   //对应参数
   
    }]
})
// 监测预览
const monitor = Mock.mock({
    'items|30': [{
        index: '@increment',   //序号
        type: () => {                                                       
            const randomLength = Mock.Random.integer(2, 4);
            let chineseCharacters = '';
            for (let i = 0; i < randomLength; i++) {
                chineseCharacters += String.fromCharCode(Mock.Random.integer(0x4e00, 0x9fa5));
            }
            return chineseCharacters;
        },     //设备类型
        preview:() => {                                                       
            const randomLength = Mock.Random.integer(5, 6);
            let chineseCharacters = '';
            for (let i = 0; i < randomLength; i++) {
                chineseCharacters += String.fromCharCode(Mock.Random.integer(0x4e00, 0x9fa5));
            }
            return chineseCharacters;
        },      //预览显示
      
   
    }]
})
// 寄存器配置
const register = Mock.mock({
    'items|30': [{
        index: '@increment',   //序号
        type:'@upper(@string("upper", 4, 5))',    //寄存器类型
        model:'@upper(@string("upper", 6, 8))',      //型号
    }]
})





module.exports = [
    // 主机协议
    {
        url: '/vue-admin-template/power/pagreement',
        type: 'get',
        response: config => {
            const items = pagreement.items
            return {
                code: 20000,
                data: {
                    total: items.length,
                    items: items
                }
            }
        }
    },
    // 主机报警
    {
        url: '/vue-admin-template/power/hostalarm',
        type: 'get',
        response: config => {
            const items = hostalarm.items
            return {
                code: 20000,
                data: {
                    total: items.length,
                    items: items
                }
            }
        }
    },
    // 设备标签
    {
        url: '/vue-admin-template/power/plabel',
        type: 'get',
        response: config => {
            const items = plabel.items
            return {
                code: 20000,
                data: {
                    total: items.length,
                    items: items
                }
            }
        }
    },
    // 设备分析
    {
        url: '/vue-admin-template/power/panalyze',
        type: 'get',
        response: config => {
            const items = panalyze.items
            return {
                code: 20000,
                data: {
                    total: items.length,
                    items: items
                }
            }
        }
    },
    // 监测预览
    {
        url: '/vue-admin-template/power/monitor',
        type: 'get',
        response: config => {
            const items = monitor.items
            return {
                code: 20000,
                data: {
                    total: items.length,
                    items: items
                }
            }
        }
    },
    // 寄存器配置
    {
        url: '/vue-admin-template/power/register',
        type: 'get',
        response: config => {
            const items = register.items
            return {
                code: 20000,
                data: {
                    total: items.length,
                    items: items
                }
            }
        }
    },
]
